/**
 * @file e2_t2_q4.c
 * @date 2022-03-02
 * 
 * @copyright Copyright (c) 2022 cnzyx MIT Licence
 * 
 */

#include<stdio.h>
#include<stdlib.h>

long fun(long num,int conv){
    int len=0;
    long temp=0,result=0;
    for(;num>0;num/=conv,++len){
        temp*=10;
        temp+=num%conv;
    }
    for(;len>0;temp/=10,--len){
        result*=10;
        result+=temp%10;
    }
    return result;
}

int main(int argc, char const *argv[])
{
    //UTF-8
    system("chcp 65001");
    int conv;
    long in_num,result;
    printf("请输入一个十进制整数：");
    scanf("%ld,",&in_num);
    printf("输入要转换的进制数：");
    scanf("%d",&conv);
    result=fun(in_num,conv);
    printf("结果：%ld\n",result);
    
    //Pause console
    system("pause");
    return 0;
}
